package com.task.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.task.bean.Comment;
import com.task.service.ICommentService;
import com.task.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author liuzhe
 * @since 2021-04-10
 */
@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    private ICommentService commentService;

    @PostMapping("/add")
    public ResultVo add(@RequestBody Comment comment) {
        comment.setCreateTime(new Date());
        return ResultVo.success(commentService.save(comment));
    }

    @GetMapping("/list")
    public ResultVo list(int evaId) {
        return ResultVo.success(commentService.queryCommentListByEvaId(evaId));
    }

}

